package net.qunzhi.modules.cms.controller;

import java.util.Arrays;
import net.qunzhi.common.utils.BaseQuery;
import net.qunzhi.common.annotation.SysLog;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import net.qunzhi.modules.cms.entity.TbMsgWxLogEntity;
import net.qunzhi.modules.cms.service.TbMsgWxLogService;
import net.qunzhi.common.utils.PageUtils;
import net.qunzhi.common.utils.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;


/**
 * 微信推送记录表
 *
 * @author zjr
 * @date 2021-11-08 17:38:16
 */
@Api(tags = "微信推送记录表相关")
@RestController
@RequestMapping("cms/tbMsgWxLog")
public class TbMsgWxLogController {
    @Autowired
    private TbMsgWxLogService tbMsgWxLogService;

    /**
     * 列表
     */
    @ApiOperation("列表")
    @GetMapping("/list")
    @RequiresPermissions("cms:tbMsgWxLog:list")
    public R list(BaseQuery query){
        PageUtils page = tbMsgWxLogService.queryPage(query);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @ApiOperation("信息")
    @GetMapping("/info/{id}")
    @RequiresPermissions("cms:tbMsgWxLog:info")
    public R info(@PathVariable("id") Long id){
		TbMsgWxLogEntity tbMsgWxLog = tbMsgWxLogService.getById(id);

        return R.ok().put("tbMsgWxLog", tbMsgWxLog);
    }

    /**
     * 保存
     */
    @ApiOperation("保存")
    @SysLog("微信推送记录表保存")
    @PostMapping("/save")
    @RequiresPermissions("cms:tbMsgWxLog:save")
    public R save(@RequestBody TbMsgWxLogEntity tbMsgWxLog){
		tbMsgWxLogService.save(tbMsgWxLog);

        return R.ok();
    }

    /**
     * 修改
     */
    @ApiOperation("修改")
    @SysLog("微信推送记录表修改")
    @PostMapping("/update")
    @RequiresPermissions("cms:tbMsgWxLog:update")
    public R update(@RequestBody TbMsgWxLogEntity tbMsgWxLog){
		tbMsgWxLogService.updateById(tbMsgWxLog);

        return R.ok();
    }

    /**
     * 删除
     */
    @ApiOperation("删除")
    @SysLog("微信推送记录表删除")
    @PostMapping("/delete")
    @RequiresPermissions("cms:tbMsgWxLog:delete")
    public R delete(@RequestBody Long[] ids){
		tbMsgWxLogService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
